﻿//********************************************************************************//
//创建日期：<创建日期，2010-08-02>
//创建作者：<王一飞，wangyifei@shanghai3h.com>
//功能说明：QS_YH_YONGHUSJGXB实体层次
//********************************************************************************//
#region Entity
namespace Entity
{
    using System;
    using System.Xml;
    [Serializable()]
    public class QS_YH_YONGHUSJGXB
    {

        private decimal m_dec_id;
        /// <summary>
        /// 自增量
        /// </summary>
        public decimal ID { get { return m_dec_id; } set { m_dec_id = value; } }

        private string m_str_s_yonghubh;
        /// <summary>
        /// 用户编号

        /// </summary>
        public string S_YONGHUBH { get { return m_str_s_yonghubh; } set { m_str_s_yonghubh = value; } }

        private string m_str_s_jingbianh;
        /// <summary>
        /// 井编号

        /// </summary>
        public string S_JINGBIANH { get { return m_str_s_jingbianh; } set { m_str_s_jingbianh = value; } }

        private decimal? m_dec_i_jlzt;
        /// <summary>
        /// 记录状态

        /// </summary>
        public decimal? I_JLZT { get { return m_dec_i_jlzt; } set { m_dec_i_jlzt = value; } }

        private string m_str_s_tianjiar;
        /// <summary>
        /// 添加人编号

        /// </summary>
        public string S_TIANJIAR { get { return m_str_s_tianjiar; } set { m_str_s_tianjiar = value; } }

        private DateTime? m_DT_d_tianjiarq;
        /// <summary>
        /// 添加日期

        /// </summary>
        public DateTime? D_TIANJIARQ { get { return m_DT_d_tianjiarq; } set { m_DT_d_tianjiarq = value; } }

        private string m_str_s_caozuor;
        /// <summary>
        /// 操作人

        /// </summary>
        public string S_CAOZUOR { get { return m_str_s_caozuor; } set { m_str_s_caozuor = value; } }

        private DateTime? m_DT_d_caozuorq;
        /// <summary>
        /// 操作日期

        /// </summary>
        public DateTime? D_CAOZUORQ { get { return m_DT_d_caozuorq; } set { m_DT_d_caozuorq = value; } }

        private string m_str_s_kaishiny;
        /// <summary>
        /// 开始年月

        /// </summary>
        public string S_KAISHINY { get { return m_str_s_kaishiny; } set { m_str_s_kaishiny = value; } }

        private string m_str_s_jieshuny;
        /// <summary>
        /// 结束年月

        /// </summary>
        public string S_JIESHUNY { get { return m_str_s_jieshuny; } set { m_str_s_jieshuny = value; } }

        private string m_str_s_beizhu;
        /// <summary>
        /// 备注
        /// </summary>
        public string S_BEIZHU { get { return m_str_s_beizhu; } set { m_str_s_beizhu = value; } }
        public QS_YH_YONGHUSJGXB()
        {
        }
    }
}
#endregion
#region EntityProcess
namespace BLL.Access
{
    using System;
    using System.Data;
    //using System.Data.OracleClient;
    using Entity;
    using System.Configuration;
    using System.Data.Common;
    using Platform.Data;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    using Oracle.DataAccess;
    public class QS_YH_YONGHUSJGXBProcess
    {
        #region Field
        protected string conn;
        #endregion
        #region Construction
        public QS_YH_YONGHUSJGXBProcess() { conn = Platform.Configuration.ConfigHelper.PlatformConnString; }
        #endregion
        #region public

        /// <summary>
        /// 根据QS_YH_YONGHUSJGXB实体添加或者修改QS_YH_YONGHUSJGXB信息
        /// </summary>
        public bool InsertOrUpdate(QS_YH_YONGHUSJGXB QS_YH_YONGHUSJGXB, OracleTransaction Transaction)
        {
            if (QS_YH_YONGHUSJGXB.ID == 0)
            {
                InsertQS_YH_YONGHUSJGXB(QS_YH_YONGHUSJGXB, Transaction);
            }
            else
            {
                UpdateQS_YH_YONGHUSJGXB(QS_YH_YONGHUSJGXB, Transaction);
            }
            return QS_YH_YONGHUSJGXB.ID == 0 ? false : true;
        }

        /// <summary>
        /// 根据QS_YH_YONGHUSJGXB实体添加或修改QS_YH_YONGHUSJGXB信息
        /// </summary>
        public bool InsertOrUpdate(QS_YH_YONGHUSJGXB QS_YH_YONGHUSJGXB)
        {
            return InsertOrUpdate(QS_YH_YONGHUSJGXB, null);
        }



        /// <summary>
        /// 根据QS_YH_YONGHUSJGXB主键删除QS_YH_YONGHUSJGXB信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteQS_YH_YONGHUSJGXB(decimal ID, OracleTransaction Transaction)
        {
            string spName = "CS_DelQS_YH_YONGHUSJGXB";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        /// 根据QS_YH_YONGHUSJGXB主键删除QS_YH_YONGHUSJGXB信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteQS_YH_YONGHUSJGXB(decimal ID)
        {
            return DeleteQS_YH_YONGHUSJGXB(ID, null);
        }

        /// <summary>
        /// 根据条件删除QS_YH_YONGHUSJGXB信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteQS_YH_YONGHUSJGXBsDynamic(string WhereClause, OracleTransaction Transaction)
        {
            string spName = "CS_DelQS_YH_YONGHUSJGXBsDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WhereClause;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        /// 根据条件删除QS_YH_YONGHUSJGXB信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteQS_YH_YONGHUSJGXBsDynamic(string WhereClause)
        {
            return DeleteQS_YH_YONGHUSJGXBsDynamic(WhereClause, null);
        }

        /// <summary>
        /// 根据QS_YH_YONGHUSJGXB主键选择QS_YH_YONGHUSJGXB信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>QS_YH_YONGHUSJGXB信息</returns>
        public QS_YH_YONGHUSJGXB SelectQS_YH_YONGHUSJGXB(decimal ID, OracleTransaction Transaction)
        {
            string spName = "CS_SelQS_YH_YONGHUSJGXB";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            OracleDataReader rd;
            if (Transaction == null)
                rd = OracleHelper.ExecuteReader(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                rd = OracleHelper.ExecuteReader((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (rd.Read())
            {
                QS_YH_YONGHUSJGXB QS_YH_YONGHUSJGXB = PopulateQS_YH_YONGHUSJGXB(rd);
                rd.Close();
                return QS_YH_YONGHUSJGXB;
            }
            else
                return null;
        }

        /// <summary>
        /// 根据QS_YH_YONGHUSJGXB主键选择QS_YH_YONGHUSJGXB信息
        /// </summary>
        /// <returns>QS_YH_YONGHUSJGXB信息</returns>
        public QS_YH_YONGHUSJGXB SelectQS_YH_YONGHUSJGXB(decimal ID)
        {
            return SelectQS_YH_YONGHUSJGXB(ID, null);
        }

        /// <summary>
        /// 选择所有QS_YH_YONGHUSJGXB信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>所有QS_YH_YONGHUSJGXB信息</returns>
        public DataTable SelectQS_YH_YONGHUSJGXBsAll(OracleTransaction Transaction)
        {
            string spName = "CS_SelQS_YH_YONGHUSJGXBsAll";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }

        /// <summary>
        /// 选择所有QS_YH_YONGHUSJGXB信息
        /// </summary>
        /// <returns>所有QS_YH_YONGHUSJGXB信息</returns>
        public DataTable SelectQS_YH_YONGHUSJGXBsAll()
        {
            return SelectQS_YH_YONGHUSJGXBsAll(null);
        }

        /// <summary>
        /// 根据条件选择QS_YH_YONGHUSJGXB信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>QS_YH_YONGHUSJGXB信息</returns>
        public DataTable SelectQS_YH_YONGHUSJGXBsDynamic(string WhereClause, string OrderByExpression, OracleTransaction Transaction)
        {
            string spName = "CS_SelQS_YH_YONGHUSJGXBsDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }


        /// <summary>
        /// 根据条件选择QS_YH_YONGHUSJGXB信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <returns>QS_YH_YONGHUSJGXB信息</returns>
        public DataTable SelectQS_YH_YONGHUSJGXBsDynamic(string WhereClause, string OrderByExpression)
        {
            return SelectQS_YH_YONGHUSJGXBsDynamic(WhereClause, OrderByExpression, null);
        }



        /// <summary>
        /// 根据条件选择QS_YH_YONGHUSJGXB信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>QS_YH_YONGHUSJGXB信息</returns>
        public DataTable SelectQS_YH_YONGHUSJGXBsDynamic(string WhereClause, string OrderByExpression, int PageIndex, int PageSize, OracleTransaction Transaction)
        {
            string spName = "CS_SelQS_YH_YONGHUSJGXBsDynPaged";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            storedParams[2].Value = PageIndex;
            storedParams[3].Value = PageSize;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }


        /// <summary>
        /// 根据条件选择QS_YH_YONGHUSJGXB信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <returns>QS_YH_YONGHUSJGXB信息</returns>
        public DataTable SelectQS_YH_YONGHUSJGXBsDynamic(string WhereClause, string OrderByExpression, int PageIndex, int PageSize)
        {
            return SelectQS_YH_YONGHUSJGXBsDynamic(WhereClause, OrderByExpression, PageIndex, PageSize, null);
        }

        /// <summary>
        ///根据条件更新QS_YH_YONGHUSJGXB字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateQS_YH_YONGHUSJGXBsDynamic(string UpdateValue, string WhereClause, OracleTransaction Transaction)
        {
            int result = 0;
            if (UpdateValue == "" || WhereClause == "")
            {
                return 0;
            }
            string spName = "CS_UpdQS_YH_YONGHUSJGXBDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            storedParams[0].Value = UpdateValue;
            storedParams[1].Value = WhereClause;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            result = Convert.ToInt32(storedParams[2].Value);
            return result;
        }

        /// <summary>
        ///根据条件更新QS_YH_YONGHUSJGXB字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateQS_YH_YONGHUSJGXBsDynamic(string UpdateValue, string WhereClause)
        {
            return UpdateQS_YH_YONGHUSJGXBsDynamic(UpdateValue, WhereClause, null);
        }


        #endregion
        #region Private

        private int InsertQS_YH_YONGHUSJGXB(QS_YH_YONGHUSJGXB QS_YH_YONGHUSJGXB, OracleTransaction Transaction)
        {
            string spName = "CS_InsQS_YH_YONGHUSJGXB";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = QS_YH_YONGHUSJGXB.S_YONGHUBH;
            storedParams[1].Value = QS_YH_YONGHUSJGXB.S_JINGBIANH;
            storedParams[2].Value = QS_YH_YONGHUSJGXB.I_JLZT;
            storedParams[3].Value = QS_YH_YONGHUSJGXB.S_TIANJIAR;
            storedParams[4].Value = QS_YH_YONGHUSJGXB.D_TIANJIARQ;
            storedParams[5].Value = QS_YH_YONGHUSJGXB.S_CAOZUOR;
            storedParams[6].Value = QS_YH_YONGHUSJGXB.D_CAOZUORQ;
            storedParams[7].Value = QS_YH_YONGHUSJGXB.S_KAISHINY;
            storedParams[8].Value = QS_YH_YONGHUSJGXB.S_JIESHUNY;
            storedParams[9].Value = QS_YH_YONGHUSJGXB.S_BEIZHU;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            QS_YH_YONGHUSJGXB.ID = Convert.ToInt32(storedParams[10].Value);
            return result;
        }
        private bool UpdateQS_YH_YONGHUSJGXB(QS_YH_YONGHUSJGXB QS_YH_YONGHUSJGXB, OracleTransaction Transaction)
        {
            string spName = "CS_UpdQS_YH_YONGHUSJGXB";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = QS_YH_YONGHUSJGXB.S_YONGHUBH;
            storedParams[1].Value = QS_YH_YONGHUSJGXB.S_JINGBIANH;
            storedParams[2].Value = QS_YH_YONGHUSJGXB.I_JLZT;
            storedParams[3].Value = QS_YH_YONGHUSJGXB.S_TIANJIAR;
            storedParams[4].Value = QS_YH_YONGHUSJGXB.D_TIANJIARQ;
            storedParams[5].Value = QS_YH_YONGHUSJGXB.S_CAOZUOR;
            storedParams[6].Value = QS_YH_YONGHUSJGXB.D_CAOZUORQ;
            storedParams[7].Value = QS_YH_YONGHUSJGXB.S_KAISHINY;
            storedParams[8].Value = QS_YH_YONGHUSJGXB.S_JIESHUNY;
            storedParams[9].Value = QS_YH_YONGHUSJGXB.S_BEIZHU;
            storedParams[10].Value = QS_YH_YONGHUSJGXB.ID;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }


        private QS_YH_YONGHUSJGXB PopulateQS_YH_YONGHUSJGXB(IDataReader dr)
        {
            QS_YH_YONGHUSJGXB QS_YH_YONGHUSJGXB = new QS_YH_YONGHUSJGXB();
            QS_YH_YONGHUSJGXB.ID = dr["ID"] == DBNull.Value ? (decimal)0 : (decimal)dr["ID"];
            QS_YH_YONGHUSJGXB.S_YONGHUBH = dr["S_YONGHUBH"] == DBNull.Value ? null : (string)dr["S_YONGHUBH"];
            QS_YH_YONGHUSJGXB.S_JINGBIANH = dr["S_JINGBIANH"] == DBNull.Value ? null : (string)dr["S_JINGBIANH"];
            QS_YH_YONGHUSJGXB.I_JLZT = dr["I_JLZT"] == DBNull.Value ? null : (decimal?)dr["I_JLZT"];
            QS_YH_YONGHUSJGXB.S_TIANJIAR = dr["S_TIANJIAR"] == DBNull.Value ? null : (string)dr["S_TIANJIAR"];
            QS_YH_YONGHUSJGXB.D_TIANJIARQ = dr["D_TIANJIARQ"] == DBNull.Value ? null : (DateTime?)dr["D_TIANJIARQ"];
            QS_YH_YONGHUSJGXB.S_CAOZUOR = dr["S_CAOZUOR"] == DBNull.Value ? null : (string)dr["S_CAOZUOR"];
            QS_YH_YONGHUSJGXB.D_CAOZUORQ = dr["D_CAOZUORQ"] == DBNull.Value ? null : (DateTime?)dr["D_CAOZUORQ"];
            QS_YH_YONGHUSJGXB.S_KAISHINY = dr["S_KAISHINY"] == DBNull.Value ? null : (string)dr["S_KAISHINY"];
            QS_YH_YONGHUSJGXB.S_JIESHUNY = dr["S_JIESHUNY"] == DBNull.Value ? null : (string)dr["S_JIESHUNY"];
            QS_YH_YONGHUSJGXB.S_BEIZHU = dr["S_BEIZHU"] == DBNull.Value ? null : (string)dr["S_BEIZHU"];
            return QS_YH_YONGHUSJGXB;
        }


        private void AddRowNumber(DataTable dt)
        {
            dt.Columns.Add(new DataColumn("RowNumber", typeof(int)));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i][dt.Columns.Count - 1] = i + 1;
            }
        }
        #endregion
    }
}
#endregion